<?php
$config = include_once('../../public/config/config.php');
include_once('../../public/func/db.php');
include_once('../../public/func/upload.func.php');
$array = array(
	'cid' => '分类',
	'uid' => '用户id',
	'title' => '昵称',
	'content' => '内容',
);
foreach($_POST as $k=>$v){
	if(!$v){
		echo '<script>alert("'.$array[$k].'不能为空");window.location.href="/admin/article/add.php"</script>';
	}
}
$post = $_POST;
if($_FILES['pic']['error'] != 4){
	$path = '../../public/upload';
	$post['pic'] = upload($_FILES['pic'],$path);
}
$table = 'article';
$post['ctime'] = time();
$res = insert($config,$table,$post);
if($res == ''){
	echo '<script>alert("添加成功");window.location.href="/admin/article/index.php"</script>';
}else{
	echo '<script>alert("添加失败");window.location.href=history.go(-1);</script>';
}
